package com.ysd.houtaiservlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import com.google.gson.Gson;
import com.ysd.dao.impl.HomeInfoDao;
import com.ysd.util.BaseServlet;
import com.ysd.util.Result;

/**
 * Servlet implementation class HouHomeInfoServlet
 */
@WebServlet("/HouHomeInfoServlet")
public class HouHomeInfoServlet extends BaseServlet {
	HomeInfoDao hdao=new HomeInfoDao();
	public void getselect(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
		
		
		request.setAttribute("h",hdao.getAllIndex());
		
		request.getRequestDispatcher("houtai/company_edit.jsp").forward(request, response);
	}
	public void update(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
		
		
	PrintWriter out=response.getWriter();
	
	String homeInfo=request.getParameter("homeInfo").toString();
	String info=request.getParameter("info").toString();
	String culture=request.getParameter("culture").toString();
	String zsTel=request.getParameter("zsTel").toString();
	String lxTel=request.getParameter("lxTel").toString();
	String email=request.getParameter("email").toString();
	String address=request.getParameter("address").toString();
	double x=Double.parseDouble(request.getParameter("x").toString());
	double y=Double.parseDouble(request.getParameter("y").toString());
	int i=hdao.update(homeInfo,info,culture,zsTel,lxTel,email,address,x,y);
	
	Gson g=new Gson();
	Result res=new Result(200, "true", i, "succes");
	out.print(g.toJson(res));
	out.flush();
	out.close();
		
		
	}
}
